package gui;

import java.awt.BorderLayout;

import javax.swing.JPanel;

public class OptionPanel extends JPanel {

	private static final long serialVersionUID = -7607387815244409152L;
	private JPanel currentPanel = null;

	public OptionPanel() {
		this.setLayout(new BorderLayout());
		this.setOpaque(false);
	}
	
	public void clearPanel() {
		removeCurrent();
	}
	
	public void setPanel(JPanel panel) {
		removeCurrent();
		currentPanel = panel;
		add(panel, BorderLayout.CENTER);
		panel.repaint();
		revalidate();
		this.invalidate();
	}

	private void removeCurrent() {
		if (currentPanel != null) {
			remove(currentPanel);
			revalidate();
			currentPanel = null;
		}
	}
}
